package priv.dajie.tzzq.spider.model;

import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class SpiderInfo {

    private BlockingQueue<String> heros;
    private Map<String, String> heroCN;
    private BlockingQueue<String> types;
    private Map<String, String> typeCN;
    private Map<String, String> rarityCN;

    public SpiderInfo(Map<String, String> heroCN, Map<String, String> rarityCN, Map<String, String> typeCN){
        this.heroCN = heroCN;
        this.rarityCN = rarityCN;
        this.typeCN = typeCN;
        heros = new ArrayBlockingQueue<String>(200);
        types = new ArrayBlockingQueue<String>(100);
        heros.addAll(heroCN.keySet());
        types.addAll(typeCN.keySet());
    }

    public String getHeroCN(String heroEN){
        return heroCN.get(heroEN);
    }

    public String getTypeCN(String typeEN){
        return typeCN.get(typeEN);
    }

    public String getRarityCN(String rarityEN){
        return rarityCN.get(rarityEN);
    }

    public Map<String, String> getRarity(){
        return rarityCN;
    }

    public boolean isHerosEmpty(){
        return heros.isEmpty();
    }

    public InfoElement getInfoElement(){
        if(!heros.isEmpty())
            return new InfoElement(heros.poll(), ElementType.HERO);
        if(!types.isEmpty())
            return new InfoElement(types.poll(), ElementType.TYPE);
        return null;
    }

    public String getHero(){
        return heros.poll();
    }

    public boolean isTypesEmpty(){
        return types.isEmpty();
    }

    public String getType(){
        return types.poll();
    }

    public int getSize(){
        return heros.size()+types.size();
    }

}
